﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CPPEI.Coolzon.Core;
using CPPEI.Coolzon.Core.Data;
using CPPEI.Coolzon.Core.Repositories;

namespace CPPEI.Coolzon.ManagementCenter
{
    public partial class WebTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Solution solution = new Solution();
            solution.Id = Guid.NewGuid();
            solution.Name  = "1111";
            solution.Caption = "222";
            solution.Type = "333";
            solution.IsEnable = true;

            AssignedPrivilege ap = new AssignedPrivilege();
            ap.Id = Guid.NewGuid();
            ap.ObjectId = Guid.NewGuid();
            ap.ObjectType = "111";
            ap.ObjectData = "222";
            ap.PrivilegeId = Guid.NewGuid();

            using (DbContext context = new DbContext())
            {
                ISolutionRepository privilegeRepository = RepositoryFactory.Create<ISolutionRepository>();
                privilegeRepository.CreateSolution(context, solution);
                solution.Name = "121212";
                solution.Caption = "232323";
                solution.Type = "343434";
                privilegeRepository.UpdateSolution(context, solution);

                Solution s = privilegeRepository.GetSolution(context, solution.Id);
                PagedList<Solution> ps = privilegeRepository.GetSolutionList(context, 0, int.MaxValue);
                privilegeRepository.RemoveSolution(context, solution);

                //IAssignedPrivilegeRepository iap = RepositoryFactory.Create<IAssignedPrivilegeRepository>();
                //iap.CreateAssignedPrivilege(context, ap);
                //ap.ObjectData = "1212";
                //ap.ObjectType = "232323";
                //iap.UpdateAssignedPrivilege(context, ap);

                //AssignedPrivilege ss = iap.GetAssignedPrivilege(context, ap.Id);
                //PagedList<AssignedPrivilege> pss = iap.GetAssignedPrivilegeList(context, 0, int.MaxValue);
                //iap.RemoveAssignedPrivilege(context, ap);

                //IUserRepository iup = RepositoryFactory.Create<IUserRepository>();
                //User user = new User();
                //user.Id = Guid.NewGuid();
                //user.Account = "111";
                //user.Name = "222";
                //user.Password = "333";
                //iup.CreateUser(context, user);
                //user.Account = "121212";
                //user.Name = "232323";
                //user.Password = "343434";
                //iup.UpdateUser(context, user);
                //User u = iup.GetUser(context, user.Id);
                //PagedList<User> pu = iup.GetUserList(context, 0, int.MaxValue);
                //iup.RemoveUser(context, user);

                //IPrivilegeRepository ipr = RepositoryFactory.Create<IPrivilegeRepository>();
                //Privilege p = new Privilege();
                //p.Id = Guid.NewGuid();
                //p.Code = "111";
                //p.Name = "222";
                //p.Type = "333";
                //ipr.CreatePrivilege(context, p);
                //p.Code = "1212";
                //p.Name = "2323";
                //p.Type = "3434";
                //ipr.UpdatePrivilege(context, p);
                //Privilege tp = ipr.GetPrivilege(context, p.Id);
                //PagedList<Privilege> pp = ipr.GetPrivilegeList(context, 0, int.MaxValue);
                //ipr.RemovePrivilege(context, p);

                //IUserPrivilegeRepository iupr = RepositoryFactory.Create<IUserPrivilegeRepository>();
                //UserPrivilege upp = new UserPrivilege();
                //upp.Id = Guid.NewGuid();
                //upp.UserId = Guid.NewGuid();
                //upp.PrivilegeId = Guid.NewGuid();
                //iupr.CreateUserPrivilege(context, upp);
                //upp.PrivilegeId = Guid.NewGuid();
                //upp.UserId = Guid.NewGuid();
                //iupr.UpdateUserPrivilege(context, upp);
                //PagedList<UserPrivilege> tupp = iupr.GetUserPrivilege(context, upp.UserId);
                //PagedList<UserPrivilege> pup = iupr.GetUserPrivilegeList(context, 0, int.MaxValue);
                //iupr.RemoveUserPrivilege(context, upp);
            }
        }
    }
}